package com.sinheldrin.musicplayer.player
{
	import com.sinheldrin.musicplayer.music.Music;
	import com.sinheldrin.musicplayer.music.Playlist;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	import mx.events.PropertyChangeEvent;
	import mx.events.PropertyChangeEventKind;

	public class PlayerModel extends EventDispatcher
	{
		public static const VOLUME_CHANGE:String = "volumeChange";
		
		public function PlayerModel()
		{
		}
		
		private var _isPlaying:Boolean = false;
		[Bindable]
		public function get isPlaying():Boolean
		{
			return _isPlaying;
		}
		private function set isPlaying(value:Boolean):void
		{
			_isPlaying = value;
		}
		
		private var _currentPlaylist:Playlist = null;
		[Bindable]
		public function get currentPlaylist():Playlist
		{
			return _currentPlaylist;
		}
		public function set currentPlaylist(value:Playlist):void
		{
			_currentPlaylist = value;
		}
		
		private var _currentMusic:Music = null;
		[Bindable]
		public function get currentMusic():Music
		{
			return _currentMusic;
		}
		public function set currentMusic(value:Music):void
		{
			_currentMusic = value;
		}
		
		private var _volume:Number = 50;
		[Bindable(event=VOLUME_CHANGE)]
		public function get volume():Number
		{
			return _volume;
		}
		public function set volume(value:Number):void
		{
			if (_volume != value)
			{
				_volume = value;
				dispatchEvent(new Event(VOLUME_CHANGE));
			}
		}
		
		public static const AUTO_PLAY_CHANGE:String = "playerAutoPlayChange";
		private var _autoPlay:Boolean = false;
		[Bindable(event=AUTO_PLAY)]
		public function get autoPlay():Boolean
		{
			return _autoPlay;
		}
		public function set autoPlay(value:Boolean):void
		{
			if( _autoPlay !== value)
			{
				_autoPlay = value;
				dispatchEvent(new Event(AUTO_PLAY_CHANGE));
			}
		}

		public static const RANDOM_CHANGE:String = "playerRandomChange";
		private var _random:Boolean = false;
		[Bindable(event=RANDOM_CHANGE)]
		public function get random():Boolean
		{
			return _random;
		}
		public function set random(value:Boolean):void
		{
			if( _random !== value)
			{
				_random = value;
				dispatchEvent(new Event(RANDOM_CHANGE));
			}
		}

	}
}